#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int find(vector<int> &f, int x)
{
	return f[x] == x ? x : f[x] = find(f, f[x]);
}

int merge(vector<int> &f, int x, int y)
{
	int fx = find(f, x);
	int fy = find(f, y);
	if (fx == fy) {
		return 1;
	} else {
		f[fx] = fy;
	}
	return 0;
}

int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	vector<vector<int>> gh(n + 1);
	vector<int> father(n + 1, 0);
	iota(father.begin(), father.end(), 0);

	int cnt = 0;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		//gh[u].push_back(v);
		cnt += merge(father, u, v);
	}
	cout << cnt << endl;
	return 0;
}